package edu.towson.cosc455.JohnCarloSalter.compiler;

public class UnitTester {
	
	public static MyLexicalAnalyzer lexer = new MyLexicalAnalyzer("#HAI	#MAEK HEAD	#GIMMEH TITLE The Simpson Family #MKAY #OIC "
			+ "#MAEK PARAGRAF The members of the #GIMMEH BOLD Simpsons #MKAY family are: #MAEK LIST #GIMMEH ITEM Homer Simpson #MKAY "
			+ "#GIMMEH ITEM Marge Simpson #MKAY #GIMMEH ITEM Bart Simpson #MKAY #GIMMEH ITEM Lisa Simpson #MKAY #GIMMEH ITEM Maggie Simpson #MKAY "
			+ " #OIC	#OIC #KTHXBYE"); 
	
	/*public static void main(String[] args) throws FileNotFoundException {
		//This is to test our file-to-string implementation.
		String theString = "";
		File inFile = new File("E:\\COSC 455\\Test Cases\\Test2.lol");
		Scanner lineScan = new Scanner(inFile);
		while(lineScan.hasNextLine()) {
			theString = theString + lineScan.nextLine();
			if(lineScan.hasNextLine()) {
				theString = theString + "\n";
			}
		}
		System.out.println(theString);
		lineScan.close();
	}*/
	
	public static boolean testMyLexicalAnalyzer() {
		//Tests to see if the lexical analyzer returns tokens in the way we expect.
		//Returns true if this is the case.
		Compiler.token = "";
		String lolcode = "#HAI #OBTW this is random text #MAEK HEAD more text\n" +
						 "#I HAS A these tags #oic are randomly allocated and don't actually\n" +
						 "make any sense in Lolcode #KTHXBAI";
		System.out.println("Our loldoc says:\n" + lolcode + "\n\n");
		
		MyLexicalAnalyzer lexer = new MyLexicalAnalyzer(lolcode);
		
		System.out.println("The legal tokens we found were: ");
		do {
			lexer.getNextToken();
			System.out.print(Compiler.token);
		} while(!Compiler.token.equals(""));
		//If we reach this stage without hitting any errors, we've passed the unit test!
		return true;
	}
	
	public static boolean testMyLexicalAnalyzer(String lolcode) {
		//Tests to see if the lexical analyzer returns tokens in the way we expect.
		//Returns true if this is the case.
		Compiler.token = "";

		System.out.println("Our loldoc says:\n" + lolcode + "\n\n");
		
		MyLexicalAnalyzer lexer = new MyLexicalAnalyzer(lolcode);
		
		System.out.println("The legal tokens we found were: ");
		do {
			lexer.getNextToken();
			System.out.print(Compiler.token);
		} while(!Compiler.token.equals(""));
		//If we reach this stage without hitting any errors, we've passed the unit test!
		return true;
	}
	
	public static boolean testMySyntaxAnalyzer() {

		//We have verified that this works previously.
		
		MySyntaxAnalyzer parser = new MySyntaxAnalyzer();
		lexer.getNextToken();
		parser.lolcode();
		parser.printParseTree();
		System.out.println();
		return true; //If we don't have an error, this will return true.
	}
	
}
